package org.wit.ecommerce.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
 * 
 * @author Justin
 *
 */
@Entity
@Table(name="jec_discount")
public class Discount implements Serializable{
	private static final long serialVersionUID = -4133080434396031460L;
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	
	@Column(nullable=false, length=50)
	private String discountNo;
	
	@Column(nullable=false)
	private BigDecimal amount;
	
	@Column(nullable=false)
	private Date startDate;
	
	@Column(nullable=false)
	private Date expireDate;
	
	
	public static final int UNUSED = 0;
	public static final int USED = 1;
	@Column(nullable=false)
	private int status = UNUSED;
	
	@Column(length=80)
	private String usedBy;
	
	@Column
	private Timestamp usedDate;
	
	public String getStatusAsString(){
		if(status == UNUSED){
			return "UNUSED";
		}else{
			return "USED";
		}
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getDiscountNo() {
		return discountNo;
	}
	public void setDiscountNo(String discountNo) {
		this.discountNo = discountNo;
	}
	public BigDecimal getAmount() {
		return amount;
	}
	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}
	public Date getStartDate() {
		return startDate;
	}
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	public Date getExpireDate() {
		return expireDate;
	}
	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public String getUsedBy() {
		return usedBy;
	}
	public void setUsedBy(String usedBy) {
		this.usedBy = usedBy;
	}
	public Timestamp getUsedDate() {
		return usedDate;
	}
	public void setUsedDate(Timestamp usedDate) {
		this.usedDate = usedDate;
	}
}
